package org.car.word.service.util;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.stereotype.Component;

import reactor.core.publisher.Mono;


/**
 * @author szw
 * @ClassName: MyAbstractHealthIndicator
 * @Description: 继承方法实现自定义端口
 * @date 2019年2月16日
 */
@Component("myHealth")
public class MyAbstractHealthIndicator extends AbstractHealthIndicator {

    /**
     * 自定义版本号
     */
    private static final String VERSION = "v1.0.0";

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        int code = check();
        if (code != 0) {
            builder.down().withDetail("code", code).withDetail("version", VERSION).build();
        }
        builder.withDetail("code", code)
                .withDetail("version", VERSION).up().build();
    }


    public int check() {
        return 0;
    }
}
